import 'dart:ui' show Color, VoidCallback;

import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/text.dart' show TextStyle;
import 'package:flutter_flame/testFunction/testFunction.dart';
import 'package:flutter_flame/worlds/game/state/SeedSelectionState.dart';

import 'SeedChooserBackground.dart';
import 'SeedChooserButtonGlow.dart';

class StartButton extends TextComponent with HoverCallbacks, TapCallbacks {
  static TextStyle? textStyle = TextStyle(
    fontSize: 21,
    color: Color.fromRGBO(186, 151, 83, 1),
  );
  late SeedChooserButtonGlow seedChooserButtonGlow;
  late SeedChooserBackground seedChooserBackground;
  double parentOffsetY;
  SeedSelectionState state;
  VoidCallback complete;

  StartButton(this.parentOffsetY, this.state, this.complete);

  @override
  Future<void> onLoad() async {
    text = '一起摇滚吧！';
    position = Vector2.zero();
    textRenderer = TextPaint(style: textStyle);
    position = Vector2(218, parentOffsetY + 6);
    seedChooserBackground = parent as SeedChooserBackground;
    seedChooserButtonGlow = SeedChooserButtonGlow(complete);

    TestFunction.autoBegin(() {
      add(seedChooserButtonGlow);
    });
    return super.onLoad();
  }

  @override
  void onHoverEnter() {
    if (seedChooserBackground.startButtonBackground.enable) {
      add(seedChooserButtonGlow);
    }
  }

  @override
  void onHoverExit() {
    if (seedChooserBackground.startButtonBackground.enable) {
      remove(seedChooserButtonGlow);
    }
  }
}
